import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {CommHttpService} from '../../core/comm.http.service';
import {SERVERS_NAME} from '../../config/config';
import {HttpService} from '../../core/http.service';

@Injectable()
export class HomeService extends CommHttpService {
    protected preUrl = `${SERVERS_NAME.COURSE_SERVER}base/courseArrange/`;

    constructor(protected http: HttpService) {
        super(http);
    }

    /**********接口部分*************/
    /**
     * 获取我的实训室
     */
    getEquipmentData(): Observable<any> {
        return this.http.post({}, `${SERVERS_NAME.EQUIPMENT_SERVER}my/Room/room8`);
    }

    /**
     * 查询学年列表
     */
    year(): Observable<any> {
        return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}sys/semester/list`);
    }

    /**
     * 查询月视图课表
     */
    monthCourse(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}arrangeMonth`);
    }

    /**
     * 所有月份-周-课节
     */
    getCurrentYear(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}current`);
    }

    /**
     * 查询日视图课表-date
     */
    arrangeWeek(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}arrangeWeekByDateOneself`);
    }

    /**
     * 查询周视图课表--周选择改变时
     */
    arrangeWeeks(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}arrangeWeek`);
    }

    /**
     * 查询周视图课表--月视图点击进去周视图时
     */
    arrangeWeekByDate(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}arrangeWeekByDate`);
    }

    /**
     * 查询日视图课表-week
     */
    arrangeWeekByWeek(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}arrangeWeekByOneself`);
    }

    /**
     * 课节查询列表
     */
    getSectionList(): Observable<any> {
        return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}sys/section/list`);
    }

    /**
     * 查学期下的教学任务下拉
     */
    getCourseTaskList(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.COURSE_SERVER}base/courseTask/findAllBySemesterId`);
    }

    /**
     * 工种教室列表
     */
    getRoomList(): Observable<any> {
        return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}sys/room/findListAll`);
    }

    /**
     * 教师列表
     */
    getTeacherList(): Observable<any> {
        return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}sys/teacher/list`);
    }

    /**
     * 班级列表
     */
    getClassList(): Observable<any> {
        return this.http.post([], `${SERVERS_NAME.SECURITY_SERVER}sys/classes/list`);
    }

    /**
     * 校验排课
     */
    validatorArrange(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}validatorArrange`, false);
    }

    /**
     * 保存排课
     */
    save(data, url): Observable<any> {
        return this.http.post(data, `${this.preUrl}` + url);
    }

    /**
     * 排课信息查询
     */
    findArrangeById(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}findArrangeById`, false);
    }

    /**
     * 删除信息查询
     */
    deleteArrange(data): Observable<any> {
        return this.http.post(data, `${this.preUrl}deleteArrange`);
    }

    /**
     * 查询用户自定义菜单
     */
    teachMenu(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/module/teacherMenu`);
    }

    /**
     * 查询二级所有子菜单
     */
    childMenu(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/module/listChildMenu`);
    }

    /**
     * 用户自定义菜单选择
     */
    customMenu(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/module/customMenu`);
    }

    /**
     * 学习任务
     */
    learnTasks(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.COURSE_SERVER}learning/task/learnTask`);
    }

    /**
     * 查询我的课堂
     */
    myClassroom(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.COURSE_SERVER}classroom/classroom/listMyClassroom`);
    }

    /**
     * 查询所有待办事项
     */
    todos(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/user/todos`);
    }
}
